1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * @addtogroup Choreographer
19  * @{
20  */
21 
22 /**
23  * @file choreographer.h
24  */
25 
26 module android.ndk.choreographer;
27 
28 import core.stdc.config;
29 
30 import arsd.jni;
31 import android.ndk;
32 
33 extern (C):
34 nothrow:
35 @nogc:
36 
37 struct AChoreographer;
38 
39 /**
40  * Prototype of the function that is called when a new frame is being rendered.
41  * It's passed the time that the frame is being rendered as nanoseconds in the
42  * CLOCK_MONOTONIC time base, as well as the data pointer provided by the
43  * application that registered a callback. All callbacks that run as part of
44  * rendering a frame will observe the same frame time, so it should be used
45  * whenever events need to be synchronized (e.g. animations).
46  */
47 alias AChoreographer_frameCallback = void function (c_long frameTimeNanos, void* data);
48 
49 /**
50  * Prototype of the function that is called when a new frame is being rendered.
51  * It's passed the time that the frame is being rendered as nanoseconds in the
52  * CLOCK_MONOTONIC time base, as well as the data pointer provided by the
53  * application that registered a callback. All callbacks that run as part of
54  * rendering a frame will observe the same frame time, so it should be used
55  * whenever events need to be synchronized (e.g. animations).
56  */
57 alias AChoreographer_frameCallback64 = void function (long frameTimeNanos, void* data);
58 
59 /**
60  * Get the AChoreographer instance for the current thread. This must be called
61  * on an ALooper thread.
62  */
63 AChoreographer* AChoreographer_getInstance ();
64 
65 /**
66  * Deprecated: Use AChoreographer_postFrameCallback64 instead.
67  */
68 void AChoreographer_postFrameCallback (
69     AChoreographer* choreographer,
70     AChoreographer_frameCallback callback,
71     void* data);
72 
73 /**
74  * Deprecated: Use AChoreographer_postFrameCallbackDelayed64 instead.
75  */
76 void AChoreographer_postFrameCallbackDelayed (
77     AChoreographer* choreographer,
78     AChoreographer_frameCallback callback,
79     void* data,
80     c_long delayMillis);
81 
82 /* __ANDROID_API__ >= 24 */
83 
84 /**
85  * Power a callback to be run on the next frame.  The data pointer provided will
86  * be passed to the callback function when it's called.
87  */
88 void AChoreographer_postFrameCallback64 (
89     AChoreographer* chroreographer,
90     AChoreographer_frameCallback64 callback,
91     void* data);
92 
93 /**
94  * Post a callback to be run on the frame following the specified delay.  The
95  * data pointer provided will be passed to the callback function when it's
96  * called.
97  */
98 void AChoreographer_postFrameCallbackDelayed64 (
99     AChoreographer* choreographer,
100     AChoreographer_frameCallback64 callback,
101     void* data,
102     uint delayMillis);
103 
104 /* __ANDROID_API__ >= 29 */
105 
106 // ANDROID_CHOREOGRAPHER_H
107 
108 /** @} */